package max.ubitest.pipe.view
{
	import flash.events.MouseEvent;
	
	import max.ubitest.pipe.events.PipeEvent;
	
	import org.robotlegs.mvcs.Mediator;
	
	public class ComponentRendererMediator extends Mediator
	{
		[Inject]
		public var view:ComponentRenderer;
		
		public function ComponentRendererMediator()
		{
			super();
		}
		
		override public function onRegister():void{
			eventMap.mapListener(view, MouseEvent.CLICK, onClick);
		}
		
		override public function preRemove():void{
			eventMap.unmapListener(view, MouseEvent.CLICK, onClick);
		}
		
		private function onClick(e:MouseEvent):void{
			var evt:PipeEvent = new PipeEvent(PipeEvent.MAPPED_COMPONENT_SELECTED, view);
			dispatch(evt);
		}
	}
}